package com.thghh.diablo2;

import cn.hutool.core.io.FileUtil;
import org.yaml.snakeyaml.Yaml;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Map;

/**
 * TODO: this
 *
 * @author pengzhikang
 * @version 1.0
 * @date 2021/12/2 0002 21:00
 */
public class DiabloApplication {

    /**
     * 主要
     *
     * @param args arg游戏
     * @author pengzhikang
     * @date 2022/04/12
     */
    public static void main(String[] args) {
        InputStream inputStream = null;
        try {
            inputStream = new FileInputStream("H:\\game\\Diablo2\\技能石\\JiNeng.yml");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        File savaFile = new File("H:\\game\\Diablo2\\技能石");

        Yaml yaml = new Yaml();
        Map<String, Object> properties = yaml.loadAs(inputStream, Map.class);
        for (Map.Entry<String, Object> zhiye : properties.entrySet()) {
            String key = zhiye.getKey();
            File keyFilee = new File(savaFile, key);
            FileUtil.mkdir(keyFilee);

            System.out.println(key);
            Map<String, Object> value = (Map<String, Object>) zhiye.getValue();
            for (Map.Entry<String, Object> jineng : value.entrySet()) {
                String jn = jineng.getKey();
                File jnFile = new File(keyFilee, jn);

                File xilei = new File(keyFilee, jn + ".d2i");
                FileUtil.touch(xilei);

                String jnValuee = (String) jineng.getValue();
                String[] arr = jnValuee.split(" ");
                for (int i = 0; i < arr.length; i++) {
                    File aFile = new File(jnFile, (i + 1) + " " + arr[i] + ".d2i");
                    FileUtil.touch(aFile);
                }
                System.out.println(jn);
                System.out.println(jnValuee);
            }
        }
    }
}
